﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using CKEditor.NET;
using System.Collections.Generic;
using System.IO;

namespace FinalProject
{
    public partial class TaoHoSoThongTinCaNhan : System.Web.UI.Page
    {
        string pathimage = "Image/sam_resumephoto.png";        

        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Form.Attributes.Add("enctype", "multipart/form-data");
            if (!IsPostBack)
            {
                try
                {
                    string str = Request["exist"];
                    if (str == null)
                    {
                        try
                        {
                            Utility.indexHoSo = int.Parse(Request["id"]);
                            if (Utility.indexHoSo >= 0)
                            {
                                Utility.HoSoCurrent = new HoSo(Utility.UserCurrent.LstHoSo[Utility.indexHoSo]);
                            }
                        }
                        catch { Utility.indexHoSo = -1; }
                    }                    
                    InitHoSo(Utility.HoSoCurrent);
                }
                catch {  }           
            }
            else
            {
                #region Events
                btnThoat.Click += new EventHandler(btnThoat_Click);
                btnLuu.Click += new EventHandler(btnLuu_Click);
                ddlTinhThanh.SelectedIndexChanged += new EventHandler(ddlTinhThanh_SelectedIndexChanged);
                ddlQuocGia.SelectedIndexChanged += new EventHandler(ddlQuocGia_SelectedIndexChanged);
                btnHoanTat.Click += new EventHandler(btnHoanTat_Click);
                btnQuayLai.Click += new EventHandler(btnQuayLai_Click);                

                btnTTTKLuu.Click += new EventHandler(btnTTTKLuu_Click);
                btnHVBCLuu.Click += new EventHandler(btnHVBCLuu_Click);
                btnKNLVLuu.Click += new EventHandler(btnKNLVLuu_Click);
                btnMTNNLuu.Click += new EventHandler(btnMTNNLuu_Click);
                btnTTNBLuu.Click += new EventHandler(btnTTNBLuu_Click);
                btnKNNBLuu.Click += new EventHandler(btnKNNBLuu_Click);
                
                lbtCapNhatMTNN.Click += new EventHandler(lbtCapNhatMTNN_Click);
                lbtCapNhatTTNB.Click += new EventHandler(lbtCapNhatTTNB_Click);
                lbtXoaTTNB.Click += new EventHandler(lbtXoaTTNB_Click);
                lbtCapNhatKNNB.Click += new EventHandler(lbtCapNhatKNNB_Click);

                lbtThemTTTK.Click += new EventHandler(lbtThemTTTK_Click);
                grvTTTK.RowDeleting += new GridViewDeleteEventHandler(grvTTTK_RowDeleting);                
                grvTTTK.SelectedIndexChanging += new GridViewSelectEventHandler(grvTTTK_SelectedIndexChanging);

                lbtThemKNLV.Click += new EventHandler(lbtThemKNLV_Click);
                grvKNVL.RowDeleting += new GridViewDeleteEventHandler(grvKNVL_RowDeleting);
                grvKNVL.SelectedIndexChanging += new GridViewSelectEventHandler(grvKNVL_SelectedIndexChanging);

                lbtThemHVBC.Click += new EventHandler(lbtThemHVBC_Click);
                grvHVBC.RowDeleting += new GridViewDeleteEventHandler(grvHVBC_RowDeleting);
                grvHVBC.SelectedIndexChanging += new GridViewSelectEventHandler(grvHVBC_SelectedIndexChanging);
                #endregion
            }
        }

        #region Event of Gridview
        void grvHVBC_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            try
            {
                int index = e.NewSelectedIndex;
                Utility.indexHocVanBangCap = index;
                RefreshHocVanBangCap(Utility.HoSoCurrent.LstHocVanBangCap[index]);
                divRichBoxHVBC.Style["display"] = "block";
                divShowHocVanBangCap.Style["display"] = "none";
            }
            catch { } 
        }

        void grvHVBC_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                int index = e.RowIndex;
                Utility.HoSoCurrent.LstHocVanBangCap.RemoveAt(index);
                BidingHocVanBangCap(Utility.HoSoCurrent.LstHocVanBangCap);
            }
            catch { }
        }

        void lbtThemHVBC_Click(object sender, EventArgs e)
        {
            try
            {
                divShowHocVanBangCap.Style["display"] = "none";
                divRichBoxHVBC.Style["display"] = "block";
            }
            catch { }
        }

        void grvKNVL_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            try
            {
                int index = e.NewSelectedIndex;
                Utility.indexKinhNghiemLamViec = index;
                RefreshKinhnghiemLamViec(Utility.HoSoCurrent.LstKinhNghiemLamViec[index]);
                divRichBoxKNLV.Style["display"] = "block";
                divShowKinhNghiemViecLam.Style["display"] = "none";
            }
            catch { }
        }

        void grvKNVL_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                int index = e.RowIndex;
                Utility.HoSoCurrent.LstKinhNghiemLamViec.RemoveAt(index);
                BidingKinhNghiemLamViec(Utility.HoSoCurrent.LstKinhNghiemLamViec);
            }
            catch { }
        }

        void lbtThemKNLV_Click(object sender, EventArgs e)
        {
            try
            {
                divShowKinhNghiemViecLam.Style["display"] = "none";
                divRichBoxKNLV.Style["display"] = "block";
            }
            catch { }
        }

        void grvTTTK_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            try
            {
                int index = e.NewSelectedIndex;
                Utility.indexThongTinThamKhao = index;                
                RefreshThongTinThamKhao(Utility.HoSoCurrent.LstThongTinThamKhao[index]);
                divRichBoxTTTK.Style["display"] = "block";
                divShowThongTinThamKhao.Style["display"] = "none";
            }
            catch
            {
            }
        }        

        void grvTTTK_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                int index = e.RowIndex;
                Utility.HoSoCurrent.LstThongTinThamKhao.RemoveAt(index);
                BidingThongTinThamKhao(Utility.HoSoCurrent.LstThongTinThamKhao);
            }
            catch (Exception)
            {                
            }
        }

        void lbtThemTTTK_Click(object sender, EventArgs e)
        {
            try
            {
                divRichBoxTTTK.Style["display"] = "block";
                divShowThongTinThamKhao.Style["display"] = "none";
            }
            catch { }
        }

        void lbtCapNhatKNNB_Click(object sender, EventArgs e)
        {
            UpdateKyNangNoiBat();
        }

        void lbtXoaTTNB_Click(object sender, EventArgs e)
        {
            DeleteThanhTichNoiBat();
        }

        void lbtCapNhatTTNB_Click(object sender, EventArgs e)
        {
            UpdateThanhTichNoiBat();
        }

        void lbtCapNhatMTNN_Click(object sender, EventArgs e)
        {
            UpdateMucTieuNgheNghiep();
        }
        #endregion

        #region Events of Drop Down List
        void ddlTinhThanh_SelectedIndexChanged(object sender, EventArgs e)
        {                                               
            try
            {
                ddlQuanHuyen.Items.Clear();
                Utility.LstQuanHuyen.Clear();
                if (ddlTinhThanh.SelectedIndex > 0)
                {
                    int index = ddlTinhThanh.SelectedIndex;
                    Utility.LstQuanHuyen = Utility.GetQuanHuyenList(Utility.LstTinhThanh[index - 1].ID);
                    Utility.LoadDropDownList(ref ddlQuanHuyen, Utility.LstQuanHuyen);
                }
                formHidden.Style["visibility"] = "visible";
                formTTCN.Style["visibility"] = "visible";            
            }
            catch
            {
            }
        }

        void ddlQuocGia_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                RootObject quocGia = new RootObject(Utility.LstQuocGia[ddlQuocGia.SelectedIndex - 1]);

                if (quocGia.ID == "VTN" || quocGia.Ten == "Việt Nam")
                {
                    ddlQuanHuyen.Items.Clear();
                    ddlTinhThanh.AutoPostBack = true;
                    Utility.LoadDropDownList(ref ddlTinhThanh, Utility.LstTinhThanh);
                }
                else
                {
                    ddlTinhThanh.AutoPostBack = false;
                    ddlTinhThanh.Items.Clear();
                    ddlTinhThanh.Items.Add("Quốc tế");
                    ddlTinhThanh.SelectedIndex = 0;
                    ddlQuanHuyen.AutoPostBack = false;
                    ddlQuanHuyen.Items.Clear();
                    ddlQuanHuyen.Items.Add("Quốc tế");
                    ddlQuanHuyen.SelectedIndex = 0;
                }
                formHidden.Style["visibility"] = "visible";
                formTTCN.Style["visibility"] = "visible";
            }
            catch { }
        }
        #endregion

        #region Events of Button
        // Button Luu cua Popup Thong tin lien he
        void btnLuu_Click(object sender, EventArgs e)
        {
            try
            {
                if (!CheckFormThongTinLienHe())
                {
                    formHidden.Style["visibility"] = "visible";
                    formTTCN.Style["visibility"] = "visible";
                }
                else
                {
                    InsertThongTinLienHe();
                    lblHoTen.Text = Utility.HoSoCurrent.ThongTinLienHe.HoVaLot + " " + Utility.HoSoCurrent.ThongTinLienHe.Ten;
                    lblGioiTinh.Text = Utility.HoSoCurrent.ThongTinLienHe.GioiTinh == true ? "Nam" : "Nữ";
                    lblNgaySinh.Text = Utility.HoSoCurrent.ThongTinLienHe.NgaySinh.ToShortDateString();                    
                    lblNoiCuNgu.Text = Utility.HoSoCurrent.ThongTinLienHe.DiaChi;
                    if (Utility.HoSoCurrent.ThongTinLienHe.TinhThanh.Ten == "")
                    {
                        lblNoiCuNgu.Text += ", " + Utility.HoSoCurrent.ThongTinLienHe.QuocGia.Ten;
                    }
                    else
                    {
                        lblNoiCuNgu.Text += ", " + Utility.HoSoCurrent.ThongTinLienHe.QuanHuyen.Ten +
                            ", " + Utility.HoSoCurrent.ThongTinLienHe.TinhThanh.Ten +
                            ", " + Utility.HoSoCurrent.ThongTinLienHe.QuocGia.Ten;
                    }
                    UpdatePanel2.Update();
                    formHidden.Style["visibility"] = "hidden";
                    formTTCN.Style["visibility"] = "hidden";
                }
            }
            catch { }
        }

        // Button Thoat cua Popup Thong tin lien he
        void btnThoat_Click(object sender, EventArgs e)
        {
            try
            {
                formHidden.Style["visibility"] = "hidden";
                formTTCN.Style["visibility"] = "hidden";
            }
            catch { }
        }

        // Button Luu cua Ky nang noi bat
        void btnKNNBLuu_Click(object sender, EventArgs e)
        {
            try
            {
                if (CheckKyNangNoiBat())
                {
                    InsertKyNangNoiBat();
                }
                else
                {
                }
                ShowOnlyDiv(ref divKyNangNoiBat);
                //divKyNangNoiBat.Style["display"] = "block";
            }
            catch { }
        }

        // Button Luu cua Thanh tich noi bat
        void btnTTNBLuu_Click(object sender, EventArgs e)
        {
            try
            {
                if (CheckThanhTichNoiBat())
                {
                    InsertThanhTichNoiBat();
                }
                else
                {
                }
                ShowOnlyDiv(ref divThanhTichNoiBat);
                //divThanhTichNoiBat.Style["display"] = "block";
            }
            catch { }
        }

        // Button Luu cua Muc tieu nghe nghiep
        void btnMTNNLuu_Click(object sender, EventArgs e)
        {
            if (CheckMucTieuNgheNghiep())
            {
                InsertMucTieuNgheNghiep();
            }
            else
            {
            }
            ShowOnlyDiv(ref divMucTieuNgheNghiep);
            //divMucTieuNgheNghiep.Style["display"] = "block";
        }        

        // Button Kinh nghiem lam viec
        void btnKNLVLuu_Click(object sender, EventArgs e)
        {
            if (CheckKinhNghiemLamViec())
            {
                InsertKinhNghiemLamViec();
            }
            else
            {
            }
            ShowOnlyDiv(ref divKinhNghiemViecLam);
            //divKinhNghiemViecLam.Style["display"] = "block";
        }        

        // Button Hoc van va Bang cap
        void btnHVBCLuu_Click(object sender, EventArgs e)
        {
            if (CheckHocVanVaBangCap())
            {
                InsertHocVanBangCap();
            }
            else
            {
            }
            ShowOnlyDiv(ref divTrinhDoHocVan);
            //divTrinhDoHocVan.Style["display"] = "block";
        }

        // Button Luu Thong tin tham khao
        void btnTTTKLuu_Click(object sender, EventArgs e)
        {
            if (CheckThongTinThamKhao())
            {
                InsetThongTinThamKhao();
            }
            else
            {
            }
            ShowOnlyDiv(ref divThongTinThamKhao);
            //divThongTinThamKhao.Style["display"] = "block";
        }        

        // Button Hoan tat Ho so
        void btnHoanTat_Click(object sender, EventArgs e)
        {
            if (CheckHoanTatHoSo())
            {
                Response.Redirect("TaoHoSo-HoanTat.aspx?isVisible=true&id=" + Utility.indexHoSo.ToString());                
                //Response.Redirect("TaoHoSo-HoanTat.aspx");
            }
            else
            {
                ShowOnlyDiv(ref divError);
            }
        }

        // Quay lai trang Thong tin chung
        void btnQuayLai_Click(object sender, EventArgs e)
        {
            Response.Redirect("TaoHoSo-ThongTinChung.aspx?exist=true");
        }        

        protected void btnLuuMucTieuNgheNghiep_Click(object sender, EventArgs e)
        {
            Luu_Click(ckeMucTieuNgheNghiep, true);
        }

        private void Luu_Click(CKEditorControl cke, bool isBatBuoc)
        {
            if (isBatBuoc)
            {
                if (cke.Text.Length < 10)
                {
                    // Do alert
                }
                else
                {
                    // Do somethings
                }
            }
            else
            {
                // Do somethings                
            }
        }        
        #endregion        
               
        #region Refresh
        private void Refresh()
        {
            ckeKinhNghiemLamViec.Text = "";
            ckeKyNangNoiBat.Text = "";
            ckeMucTieuNgheNghiep.Text = "";
            ckeThanhTichNoiBat.Text = "";            
            ckeTrinhDoHocVan.Text = "";
        }

        private void RefreshThongTinThamKhao(ThongTinThamKhao thongTin)
        {
            if (thongTin == null)
            {
                tbxTTTKCongTy.Text = "";
                tbxTTTKChucDanh.Text = "";
                tbxTTTKEmail.Text = "";
                tbxTTTKSDT.Text = "";
                tbxTTTKHoTen.Text = "";
            }
            else
            {                
                tbxTTTKCongTy.Text = thongTin.CongTy;
                tbxTTTKChucDanh.Text = thongTin.ChucDanh;
                tbxTTTKEmail.Text = thongTin.Email;
                tbxTTTKSDT.Text = thongTin.SDT;
                tbxTTTKHoTen.Text = thongTin.HoTen;
            }
        }

        private void RefreshKinhnghiemLamViec(KinhNghiemLamViec kinhNghiem)
        {
            if (kinhNghiem == null)
            {
                tbxKNLVCongTy.Text = "";
                tbxKNLVChucDanh.Text = "";
                tbxKNLVDenNgay.Text = "";
                tbxKNLVTuNgay.Text = "";
                ddlKNLVCapBac.SelectedIndex = 0;
                ddlKNLVNganhNghe.SelectedIndex = 0;
                ckeKinhNghiemLamViec.Text = "";
            }
            else
            {                
                tbxKNLVCongTy.Text = kinhNghiem.CongTy;
                tbxKNLVChucDanh.Text = kinhNghiem.ChucDanh;
                tbxKNLVDenNgay.Text = kinhNghiem.NgayKT.ToShortDateString();
                tbxKNLVTuNgay.Text = kinhNghiem.NgayBD.ToShortDateString();
                for (int i = 0; i < ddlKNLVCapBac.Items.Count; i++)
                {
                    if (ddlKNLVCapBac.Items[i].Text == kinhNghiem.ChucVu.Ten)
                    {
                        ddlKNLVCapBac.SelectedIndex = i;
                        break;
                    }
                }
                for (int i = 0; i < ddlKNLVNganhNghe.Items.Count; i++)
                {
                    if (ddlKNLVNganhNghe.Items[i].Text == kinhNghiem.NganhNghe.Ten)
                    {
                        ddlKNLVNganhNghe.SelectedIndex = i;
                        break;
                    }
                }                
                ckeKinhNghiemLamViec.Text = kinhNghiem.NhiemVuVaThanhTich;
            }
        }

        private void RefreshHocVanBangCap(HocVanBangCap hocVan)
        {
            if (hocVan == null)
            {
                ddlHVBCBangCapChuyenMon.SelectedIndex = 0;
                ddlHVBCChuyenNganh.SelectedIndex = 0;
                ddlHVBCTruong.SelectedIndex = 0;
                tbxHVBCDenNgay.Text = "";
                tbxHVBCTuNgay.Text = "";
                ckeTrinhDoHocVan.Text = "";
            }
            else
            {                
                for (int i = 0; i < ddlHVBCBangCapChuyenMon.Items.Count; i++)
                {
                    if (ddlHVBCBangCapChuyenMon.Items[i].Text == hocVan.BangCap.Ten)
                    {
                        ddlHVBCBangCapChuyenMon.SelectedIndex = i;
                        break;
                    }
                }
                for (int i = 0; i < ddlHVBCChuyenNganh.Items.Count; i++)
                {
                    if (ddlHVBCChuyenNganh.Items[i].Text == hocVan.ChuyenNganh.Ten)
                    {
                        ddlHVBCChuyenNganh.SelectedIndex = i;
                        break;
                    }
                }
                for (int i = 0; i < ddlHVBCTruong.Items.Count; i++)
                {
                    if (ddlHVBCTruong.Items[i].Text == hocVan.Truong.Ten)
                    {
                        ddlHVBCTruong.SelectedIndex = i;                        
                        break;
                    }
                }    
                tbxHVBCTuNgay.Text = hocVan.NgayBD.ToShortDateString();
                tbxHVBCDenNgay.Text = hocVan.NgayKT.ToShortDateString();
                ckeTrinhDoHocVan.Text = hocVan.ThongTinLienQuan;
            }
        }
        #endregion        

        #region Init tu Ho so
        private void InitHoSo(HoSo hoSo)
        {
            InitCKEditor();
            InitHoSo_ThongTinCaNhan(hoSo.ThongTinLienHe);
            InitHoSo_ThongTinLienHe(hoSo.ThongTinLienHe);
            InitHoSo_MucTieuNgheNghiep(hoSo.MucTieuNgheNghiep);
            InitHoSo_ThanhTichNoiBat(hoSo.ThanhTichNoiBat);
            InitHoSo_KinhNghiemLamViec(hoSo.LstKinhNghiemLamViec);
            InitHoSo_HocVanBangCap(hoSo.LstHocVanBangCap);
            InitHoSo_KyNangNoiBat(hoSo.KyNangNoiBat);
            InitHoSo_ThongTinThamKhao(hoSo.LstThongTinThamKhao);
        }

        private void InitCKEditor()
        {
            try
            {			
                ckeKinhNghiemLamViec.config.toolbar = new object[] { new object[] { "Bold", "Italic", "-", "NumberedList", "BulletedList" } };
                ckeKyNangNoiBat.config.toolbar = new object[] { new object[] { "Bold", "Italic", "-", "NumberedList", "BulletedList" } };
                ckeMucTieuNgheNghiep.config.toolbar = new object[] { new object[] { "Bold", "Italic", "-", "NumberedList", "BulletedList" } };
                ckeThanhTichNoiBat.config.toolbar = new object[] { new object[] { "Bold", "Italic", "-", "NumberedList", "BulletedList" } };
                ckeTrinhDoHocVan.config.toolbar = new object[] { new object[] { "Bold", "Italic", "-", "NumberedList", "BulletedList" } };                
            }
            catch
            { }
        }

        private void InitHoSo_ThongTinLienHe(ThongTinLienHe thongTin)
        {
            #region Ho ten, Email
            tbxHoVaLot.Text = thongTin.HoVaLot;
            tbxTen.Text = thongTin.Ten;
            lblEmailHide.Text = thongTin.Email;
            #endregion

            #region Ngay sinh
            try
            {
                tbxNgaySinh.Text = thongTin.NgaySinh.ToShortDateString();
            }
            catch { tbxNgaySinh.Text = ""; }
            #endregion

            #region Gioi tinh
            try
            {
                ddlGioiTinh.Items.Add("Vui lòng chọn...");
                ddlGioiTinh.Items.Add("Nam");
                ddlGioiTinh.Items.Add("Nữ");
                ddlGioiTinh.SelectedIndex = thongTin.GioiTinh == true ? 1 : 2;
            }
            catch { }
            #endregion

            #region Tinh trang hon nhan
            Utility.LoadDropDownList(ref ddlTinhTrangHonNhan, Utility.LstTinhTrangHonNhan);
            SelectedIndex(ref ddlTinhTrangHonNhan, thongTin.TinhTrangHonNhan.Ten);
            #endregion

            #region Quoc gia
            ddlQuocGia.AutoPostBack = true;
            Utility.LoadDropDownList(ref ddlQuocGia, Utility.LstQuocGia);
            SelectedIndex(ref ddlQuocGia, thongTin.QuocGia.Ten);
            #endregion

            #region Tinh thanh
            #endregion

            #region Quan Huyen
            #endregion
        }

        private void InitHoSo_ThongTinCaNhan(ThongTinLienHe thongTin)
        {
            lblHoTen.Text = thongTin.HoVaLot + " " + thongTin.Ten;
            lblGioiTinh.Text = thongTin.GioiTinh == true ? "Nam" : "Nữ";
            lblEmail.Text = "Email: " + thongTin.Email;
            try
            {
                lblNgaySinh.Text = thongTin.NgaySinh.ToShortDateString();
            }
            catch
            {
                lblNgaySinh.Text = "";
            }
            try
            {
                if (thongTin.PathImage != null && thongTin.PathImage != "")
                    imgHinhAnhCaNhan.ImageUrl = thongTin.PathImage;
                else
                    imgHinhAnhCaNhan.ImageUrl = "Image/sam_resumephoto.png";
            }
            catch { }

            #region Dia chi
            try
            {
                string strDiaChi = "";
                if (thongTin.DiaChi != null && thongTin.DiaChi != "")
                    strDiaChi = thongTin.DiaChi + ", ";

                string strQuanHuyen = "";
                if (thongTin.QuanHuyen != null && thongTin.QuanHuyen.Ten != "")
                    strQuanHuyen = thongTin.QuanHuyen.Ten + ", ";

                string strTinhThanh = "";
                if (thongTin.TinhThanh != null && thongTin.TinhThanh.Ten != "")
                    strTinhThanh = thongTin.TinhThanh.Ten + ", ";

                string strQuocGia = "";
                if (thongTin.QuocGia != null && thongTin.QuocGia.Ten != "")
                    strQuocGia = thongTin.QuocGia.Ten;

                lblNoiCuNgu.Text = strDiaChi + strQuanHuyen + strTinhThanh + strQuocGia;
            }
            catch
            {
                lblNoiCuNgu.Text = "";
            }
            #endregion
        }

        private void InitHoSo_MucTieuNgheNghiep(string content)
        {
            try
            {
                if (content != null && content != "")
                {
                    lblNoiDungMTNN.Text = content;
                    ckeMucTieuNgheNghiep.Text = "";
                    divRichBoxMTNN.Style["display"] = "none";
                    divShowMucTieuNgheNghiep.Style["display"] = "block";
                }
                else
                    ckeMucTieuNgheNghiep.Text = "";
            }
            catch { ckeMucTieuNgheNghiep.Text = ""; }
        }

        private void InitHoSo_ThanhTichNoiBat(string content)
        {
            try
            {
                if (content != null && content != "")
                {
                    lblNoiDungTTNB.Text = content;
                    ckeThanhTichNoiBat.Text = "";
                    divRichBoxTTNB.Style["display"] = "none";
                    divShowThanhTichNoiBat.Style["display"] = "block";
                }
                else
                {
                    ckeThanhTichNoiBat.Text = "";
                }
            }
            catch { ckeThanhTichNoiBat.Text = ""; }
        }

        private void InitHoSo_KinhNghiemLamViec(List<KinhNghiemLamViec> lstKinhNghiem)
        {
            try
            {
                Utility.LoadDropDownList(ref ddlKNLVCapBac, Utility.LstChucVu);
                Utility.LoadDropDownList(ref ddlKNLVNganhNghe, Utility.LstNganhNghe);

                if (lstKinhNghiem != null && lstKinhNghiem.Count > 0)
                {
                    BidingKinhNghiemLamViec(lstKinhNghiem);
                    divShowKinhNghiemViecLam.Style["display"] = "block";
                    divRichBoxKNLV.Style["display"] = "none";
                    RefreshKinhnghiemLamViec(null);
                    Utility.indexKinhNghiemLamViec = -1;
                }               
            }
            catch
            {
            }
        }

        private void InitHoSo_HocVanBangCap(List<HocVanBangCap> lstHocVan)
        {
            try
            {
                Utility.LoadDropDownList(ref ddlHVBCBangCapChuyenMon, Utility.LstBangCap);
                Utility.LoadDropDownList(ref ddlHVBCTruong, Utility.LstTruongHoc);
                Utility.LoadDropDownList(ref ddlHVBCChuyenNganh, Utility.LstChuyenNganh);

                if (lstHocVan != null && lstHocVan.Count > 0)
                {
                    BidingHocVanBangCap(lstHocVan);
                    divShowHocVanBangCap.Style["display"] = "block";
                    divRichBoxHVBC.Style["display"] = "none";
                    RefreshHocVanBangCap(null);
                    Utility.indexHocVanBangCap = -1;
                }
            }
            catch
            {
            }
        }

        private void InitHoSo_KyNangNoiBat(string content)
        {
            try
            {
                if (content != null && content != "")
                {
                    lblNoiDungKNNB.Text = content;
                    ckeKyNangNoiBat.Text = "";
                    divRichBoxKNNB.Style["display"] = "none";
                    divShowKyNangNoiBat.Style["display"] = "block";
                }
                else
                {
                    ckeKyNangNoiBat.Text = "";
                }
            }
            catch { ckeKyNangNoiBat.Text = ""; }
        }

        private void InitHoSo_ThongTinThamKhao(List<ThongTinThamKhao> lstThongTin)
        {
            try
            {
                if (lstThongTin != null && lstThongTin.Count > 0)
                {
                    BidingThongTinThamKhao(lstThongTin);
                    divRichBoxTTTK.Style["display"] = "none";
                    divShowThongTinThamKhao.Style["display"] = "block";
                    RefreshThongTinThamKhao(null);
                    Utility.indexThongTinThamKhao = -1;
                }
                else
                {
                }
            }
            catch { }
        }
        #endregion

        #region Check
        // Check Form thong tin lien he
        private bool CheckFormThongTinLienHe()
        {
            bool result = true;

            #region Ho va Chu lot
            if (tbxHoVaLot.Text == "")
            {
                lblAlertHoVaLot.Visible = true;
                result = false;
            }
            else
            {                
                lblAlertHoVaLot.Visible = false;
            }
            #endregion

            #region Ten
            if (tbxTen.Text == "")
            {
                lblAlertTen.Visible = true;
                result = false;
            }
            else
            {                
                lblAlertTen.Visible = false;
            }
            #endregion

            #region Gioi tinh
            if (ddlGioiTinh.SelectedIndex <= 0)
            {
                lblAlertGioiTinh.Visible = true;
                result = false;
            }
            else
            {                
                lblAlertGioiTinh.Visible = false;
            }
            #endregion

            #region Tinh trang hon nhan
            if (ddlTinhTrangHonNhan.SelectedIndex <= 0)
            {
                lblAlertTinhTrangHonNhan.Visible = true;
                result = false;
            }
            else
            {                
                lblAlertTinhTrangHonNhan.Visible = false;
            }
            #endregion

            #region Dia chi
            if (tbxDiaChi.Text == "")
            {
                lblAlertDiaChi.Visible = true;
                result = false;
            }
            else
            {
                lblAlertDiaChi.Visible = false;
            }
            #endregion

            #region Quoc gia
            if (ddlQuocGia.SelectedIndex <= 0)
            {
                lblAlertQuocGia.Visible = true;                
                lblAlertTinhThanh.Visible = true;
                lblAlertQuanHuyen.Visible = true;
                result = false;
            }            

            else
            {
                RootObject quocGia = new RootObject(Utility.LstQuocGia[ddlQuocGia.SelectedIndex - 1]);                
                lblAlertQuocGia.Visible = false;
                lblAlertTinhThanh.Visible = false;
                lblAlertQuanHuyen.Visible = false;

                if (quocGia.ID == "VTN" || quocGia.Ten == "Việt Nam")
                {                    
                    if (ddlTinhThanh.SelectedIndex <= 0)
                    {
                        lblAlertTinhThanh.Visible = true;                        
                        lblAlertQuanHuyen.Visible = true;
                        result = false;
                    }
                    else
                    {                        
                        lblAlertTinhThanh.Visible = false;
                        if (ddlQuanHuyen.SelectedIndex <= 0)
                        {
                            lblAlertQuanHuyen.Visible = true;
                            result = false;
                        }
                        else
                        {
                            lblAlertQuanHuyen.Visible = false;
                        }
                    }
                }
            }
            #endregion

            #region So dien thoai
            if (tbxDienThoai.Text == "")
            {
                lblAlertDienThoai.Visible = true;
                result = false;
            }
            else
            {
                lblAlertDienThoai.Visible = false;
            }
            #endregion

            return result;
        }

        // Check Muc tieu nghe nghiep - Bat buoc
        private bool CheckMucTieuNgheNghiep()
        {
            bool result = true;

            if (ckeMucTieuNgheNghiep.Text.Length < 100)
            {
                lblMTNNAlert.Visible = true;
                result = false;
            }
            else
            {
                lblMTNNAlert.Visible = false;
            }

            return result;
        }

        // Check Thanh tich noi bat
        private bool CheckThanhTichNoiBat()
        {
            bool result = true;

            if (ckeThanhTichNoiBat.Text.Length < 100)
            {
                lblTTNBAlert.Visible = true;
                result = false;
            }
            else
            {
                lblTTNBAlert.Visible = false;
            }

            return result;
        }

        // Check Kinh nghiem lam viec
        private bool CheckKinhNghiemLamViec()
        {
            bool result = true;

            #region Chuc danh
            if (tbxKNLVChucDanh.Text == "")
            {
                lblKNLVAlertChucDanh.Visible = true;
                result = false;
            }
            else
            {
                lblKNLVAlertChucDanh.Visible = false;
            }
            #endregion

            #region Cong ty
            if (tbxKNLVCongTy.Text == "")
            {
                lblKNLVAlertCongTy.Visible = true;
                result = false;
            }
            else
            {
                lblKNLVAlertCongTy.Visible = false;
            }
            #endregion

            #region Cap bac
            if (ddlKNLVCapBac.SelectedIndex <= 0)
            {
                lblKNLVAlertCapBac.Visible = true;
                result = false;
            }
            else
            {
                lblKNLVAlertCapBac.Visible = false;
            }
            #endregion

            #region Nganh nghe
            if (ddlKNLVNganhNghe.SelectedIndex <= 0)
            {
                lblKNLVAlertNganhNghe.Visible = true;
                result = false;
            }
            else
            {
                lblKNLVAlertNganhNghe.Visible = false;
            }
            #endregion

            #region Tu ngay (Chua hoan thanh)
            if (tbxKNLVTuNgay.Text == "")
            {
                lblKNLVAlertTuNgay.Visible = true;
                result = false;
            }
            else
            {
                try
                {
                    DateTime.Parse(tbxKNLVTuNgay.Text);
                    lblKNLVAlertTuNgay.Visible = false;
                }
                catch 
                {
                    lblKNLVAlertTuNgay.Visible = true;
                    result = false;
                }                
            }
            #endregion

            #region Den ngay (Chua hoan thanh)
            if (tbxKNLVDenNgay.Text == "")
            {
                lblKNLVAlertDenNgay.Visible = true;
                result = false;
            }
            else
            {
                try
                {
                    DateTime.Parse(tbxKNLVDenNgay.Text);
                    lblKNLVAlertDenNgay.Visible = false;
                }
                catch
                {
                    lblKNLVAlertDenNgay.Visible = true;
                    result = false;
                }       
            }

            if (lblKNLVAlertDenNgay.Visible == false && lblKNLVAlertTuNgay.Visible == false)
            {
                if (DateTime.Parse(tbxKNLVDenNgay.Text) < DateTime.Parse(tbxKNLVTuNgay.Text))
                {
                    lblKNLVAlertTuNgay.Visible = true;
                    lblKNLVAlertDenNgay.Visible = true;
                    result = false;
                }
            }
            #endregion

            #region Nhiem vu va Thanh tich
            if (ckeKinhNghiemLamViec.Text.Length <= 50)
            {
                lblKNLVAlertNhiemVu.Visible = true;
                result = false;
            }
            else
            {
                lblKNLVAlertNhiemVu.Visible = false;
            }
            #endregion

            return result;
        }

        // Check Hoc van va Bang cap - Bat buoc
        private bool CheckHocVanVaBangCap()
        {
            bool result = true;

            #region Bang cap chuyen mon
            if (ddlHVBCBangCapChuyenMon.SelectedIndex <= 0)
            {
                lblHVBCAlertBangCapChuyenMon.Visible = true;
                result = false;
            }
            else
            {
                lblHVBCAlertBangCapChuyenMon.Visible = false;
            }
            #endregion

            #region Truong
            if (ddlHVBCTruong.SelectedIndex <= 0)
            {
                lblHVBCAlertTruong.Visible = true;
                result = false;
            }
            else
            {
                lblHVBCAlertTruong.Visible = false;
            }
            #endregion

            #region Chuyen nganh
            if (ddlHVBCChuyenNganh.SelectedIndex <= 0)
            {
                lblHVBCAlertChuyenNganh.Visible = true;
                result = false;
            }
            else
            {
                lblHVBCAlertChuyenNganh.Visible = false;
            }
            #endregion

            #region Tu ngay (Chua hoan thanh)
            if (tbxHVBCTuNgay.Text == "")
            {
                lblHVBCAlertTuNgay.Visible = true;
                result = false;
            }
            else
            {
                try
                {
                    DateTime.Parse(tbxHVBCTuNgay.Text);
                    lblHVBCAlertTuNgay.Visible = false;
                }
                catch
                {
                    lblHVBCAlertTuNgay.Visible = true;
                    result = false;
                }  
            }
            #endregion

            #region Den ngay (Chua hoan thanh)
            if (tbxHVBCDenNgay.Text == "")
            {
                lblHVBCAlertDenNgay.Visible = true;
                result = false;
            }
            else
            {
                try
                {
                    DateTime.Parse(tbxHVBCDenNgay.Text);
                    lblHVBCAlertDenNgay.Visible = false;
                }
                catch
                {
                    lblHVBCAlertDenNgay.Visible = true;
                    result = false;
                }  
            }

            if (lblHVBCAlertDenNgay.Visible == false && lblHVBCAlertTuNgay.Visible == false)
            {
                if (DateTime.Parse(tbxHVBCDenNgay.Text) < DateTime.Parse(tbxHVBCTuNgay.Text))
                {
                    lblHVBCAlertTuNgay.Visible = true;
                    lblHVBCAlertDenNgay.Visible = true;
                    result = false;
                }
            }
            #endregion

            #region Thong tin lien quan
            if (ckeTrinhDoHocVan.Text.Length < 50)
            {
                lblHVBCAlertThongTinLienQuan.Visible = true;
                result = false;
            }
            else
            {
                lblHVBCAlertThongTinLienQuan.Visible = false;
            }
            #endregion

            return result;
        }

        // Check Ky nang noi bat - Bat buoc
        private bool CheckKyNangNoiBat()
        {
            bool result = true;

            if (ckeKyNangNoiBat.Text.Length < 100)
            {
                lblKNNBAlert.Visible = true;
                result = false;
            }
            else
            {
                lblKNNBAlert.Visible = false;
            }

            return result;
        }

        // Check Thong tin tham khao
        private bool CheckThongTinThamKhao()
        {
            bool result = true;

            #region Ho ten
            if (tbxTTTKHoTen.Text == "")
            {
                lblTTTKAlertHoTen.Visible = true;
                result = false;
            }
            else
            {
                lblTTTKAlertHoTen.Visible = false;
            }
            #endregion

            #region Chuc danh
            if (tbxTTTKChucDanh.Text == "")
            {
                lblTTTKAlertChucDanh.Visible = true;
                result = false;
            }
            else
            {
                lblTTTKAlertChucDanh.Visible = false;
            }
            #endregion

            #region Cong ty
            if (tbxTTTKCongTy.Text == "")
            {
                lblTTTKAlertCongTy.Visible = true;
                result = false;
            }
            else
            {
                lblTTTKAlertCongTy.Visible = false;
            }
            #endregion

            #region Email
            if (tbxTTTKEmail.Text == "")
            {
                lblTTTKAlertEmail.Visible = true;
                result = false;
            }
            else
            {
                lblTTTKAlertEmail.Visible = false;
            }
            #endregion

            #region SDT
            if (tbxTTTKSDT.Text == "")
            {
                lblTTTKAlertSDT.Visible = true;
                result = false;
            }
            else
            {
                lblTTTKAlertSDT.Visible = false;
            }
            #endregion

            return result;
        }

        // Check Hoan tat ho so
        private bool CheckHoanTatHoSo()
        {
            try
            {
                bool result = true;
                divError.InnerText = "Vui lòng nhập ";
                if (Utility.HoSoCurrent.ThongTinLienHe == null || Utility.HoSoCurrent.ThongTinLienHe.DiaChi == "")
                {
                    divError.InnerText += "Thông tin liên hệ, ";
                    result = false;
                }
                else
                {
                    if (Utility.HoSoCurrent.ThongTinLienHe.Ten == "")
                    {
                        divError.InnerText += "Thông tin liên hệ, ";
                        result = false;
                    }
                }

                if (Utility.HoSoCurrent.MucTieuNgheNghiep == null)
                {
                    divError.InnerText += "Mục tiêu nghề nghiệp, ";
                    result = false;
                }
                else
                {
                    if (Utility.HoSoCurrent.MucTieuNgheNghiep == "")
                    {
                        divError.InnerText += "Mục tiêu nghề nghiệp, ";
                        result = false;
                    }
                }

                if (Utility.HoSoCurrent.LstHocVanBangCap == null)
                {
                    divError.InnerText += "Học vấn & Bằng cấp, ";
                    result = false;
                }
                else
                {
                    if (Utility.HoSoCurrent.LstHocVanBangCap.Count == 0)
                    {
                        divError.InnerText += "Học vấn & Bằng cấp, ";
                        result = false;
                    }
                }

                if (Utility.HoSoCurrent.KyNangNoiBat == null)
                {
                    divError.InnerText += "Kỹ năng nổi bật, ";
                    result = false;
                }
                else
                {
                    if (Utility.HoSoCurrent.KyNangNoiBat == "")
                    {
                        divError.InnerText += "Kỹ năng nổi bật, ";
                        result = false;
                    }
                }
                
                if (!result)
                {
                    divError.InnerText = divError.InnerText.Remove(divError.InnerText.Length - 2, 2);
                    divError.InnerText += ".";
                }
                else
                    divError.InnerText = "";

                return result;
            }
            catch { return false; }
        }
        #endregion

        #region Insert Info
        private void InsertThongTinLienHe()
        {
            try
            {
                ThongTinLienHe thongTin = new ThongTinLienHe();
                thongTin.DiaChi = tbxDiaChi.Text;
                thongTin.Email = lblEmailHide.Text;
                thongTin.GioiTinh = ddlGioiTinh.SelectedIndex == 1 ? true : false;
                thongTin.HoVaLot = tbxHoVaLot.Text;
                thongTin.NgaySinh = DateTime.Parse(tbxNgaySinh.Text);
                thongTin.QuocGia = Utility.LstQuocGia[ddlQuocGia.SelectedIndex - 1];
                thongTin.SDT = tbxDienThoai.Text;
                thongTin.Ten = tbxTen.Text;
                thongTin.TinhTrangHonNhan = Utility.LstTinhTrangHonNhan[ddlTinhTrangHonNhan.SelectedIndex - 1];
                thongTin.PathImage = pathimage;
                if (ddlTinhThanh.Items.Count > 1)
                {
                    thongTin.TinhThanh = Utility.LstTinhThanh[ddlTinhThanh.SelectedIndex - 1];
                    thongTin.QuanHuyen = Utility.LstQuanHuyen[ddlQuanHuyen.SelectedIndex - 1];
                }
                else
                {
                    thongTin.TinhThanh = new RootObject();
                    thongTin.QuanHuyen = new RootObject();
                }

                Utility.HoSoCurrent.ThongTinLienHe = new ThongTinLienHe(thongTin);
            }
            catch
            {
            }
        }

        private void InsertMucTieuNgheNghiep()
        {
            try
            {
                Utility.HoSoCurrent.MucTieuNgheNghiep = ckeMucTieuNgheNghiep.Text;
                lblNoiDungMTNN.Text = Utility.HoSoCurrent.MucTieuNgheNghiep;
                ckeMucTieuNgheNghiep.Text = "";
                divRichBoxMTNN.Style["display"] = "none";
                divShowMucTieuNgheNghiep.Style["display"] = "block";
            }
            catch
            {
            }
        }

        private void InsertThanhTichNoiBat()
        {
            try
            {
                Utility.HoSoCurrent.ThanhTichNoiBat = ckeThanhTichNoiBat.Text;
                lblNoiDungTTNB.Text = Utility.HoSoCurrent.ThanhTichNoiBat;
                ckeThanhTichNoiBat.Text = "";
                divRichBoxTTNB.Style["display"] = "none";
                divShowThanhTichNoiBat.Style["display"] = "block";
            }
            catch { }
        }

        private void InsertKinhNghiemLamViec()
        {
            try
            {
                KinhNghiemLamViec kinhNghiem = new KinhNghiemLamViec(tbxKNLVCongTy.Text,
                        tbxKNLVChucDanh.Text,
                        Utility.LstChucVu[ddlKNLVCapBac.SelectedIndex - 1],
                        Utility.LstNganhNghe[ddlKNLVNganhNghe.SelectedIndex - 1],
                        DateTime.Parse(tbxKNLVTuNgay.Text),
                        DateTime.Parse(tbxKNLVDenNgay.Text),
                        ckeKinhNghiemLamViec.Text);

                if (Utility.indexKinhNghiemLamViec < 0)
                {
                    if (Utility.HoSoCurrent.LstKinhNghiemLamViec == null)
                    {
                        Utility.HoSoCurrent.LstKinhNghiemLamViec = new List<KinhNghiemLamViec>();
                    }
                    Utility.HoSoCurrent.LstKinhNghiemLamViec.Add(kinhNghiem);                    
                }
                else
                {
                    Utility.HoSoCurrent.LstKinhNghiemLamViec[Utility.indexKinhNghiemLamViec] = kinhNghiem;                        
                }
                BidingKinhNghiemLamViec(Utility.HoSoCurrent.LstKinhNghiemLamViec);
                divShowKinhNghiemViecLam.Style["display"] = "block";
                divRichBoxKNLV.Style["display"] = "none";                    
                RefreshKinhnghiemLamViec(null);
                Utility.indexKinhNghiemLamViec = -1;
            }
            catch { }
        }

        private void InsertHocVanBangCap()
        {
            try
            {
                HocVanBangCap hocVan = new HocVanBangCap(Utility.LstBangCap[ddlHVBCBangCapChuyenMon.SelectedIndex - 1],
                        Utility.LstTruongHoc[ddlHVBCTruong.SelectedIndex - 1],
                        Utility.LstChuyenNganh[ddlHVBCChuyenNganh.SelectedIndex - 1],
                        DateTime.Parse(tbxHVBCTuNgay.Text),
                        DateTime.Parse(tbxHVBCDenNgay.Text),
                        ckeTrinhDoHocVan.Text);

                if (Utility.indexHocVanBangCap < 0)
                {
                    if (Utility.HoSoCurrent.LstHocVanBangCap == null)
                    {
                        Utility.HoSoCurrent.LstHocVanBangCap = new List<HocVanBangCap>();
                    }
                    Utility.HoSoCurrent.LstHocVanBangCap.Add(hocVan);                                        
                }
                else
                {
                    Utility.HoSoCurrent.LstHocVanBangCap[Utility.indexHocVanBangCap] = hocVan;                                       
                }
                BidingHocVanBangCap(Utility.HoSoCurrent.LstHocVanBangCap);
                divShowHocVanBangCap.Style["display"] = "block";
                divRichBoxHVBC.Style["display"] = "none";
                RefreshHocVanBangCap(null);
                Utility.indexHocVanBangCap = -1;
            }
            catch { }
        }

        private void InsertKyNangNoiBat()
        {
            try
            {
                Utility.HoSoCurrent.KyNangNoiBat = ckeKyNangNoiBat.Text;
                lblNoiDungKNNB.Text = Utility.HoSoCurrent.KyNangNoiBat;
                ckeKyNangNoiBat.Text = "";
                divRichBoxKNNB.Style["display"] = "none";
                divShowKyNangNoiBat.Style["display"] = "block";
            }
            catch
            {                
            }
        }

        private void InsetThongTinThamKhao()
        {
            try
            {
                ThongTinThamKhao thongTin = new ThongTinThamKhao(tbxTTTKHoTen.Text, tbxTTTKChucDanh.Text,
                        tbxTTTKCongTy.Text, tbxTTTKEmail.Text, tbxTTTKSDT.Text);

                if (Utility.indexThongTinThamKhao < 0)
                {
                    if (Utility.HoSoCurrent.LstThongTinThamKhao == null)
                    {
                        Utility.HoSoCurrent.LstThongTinThamKhao = new List<ThongTinThamKhao>();
                    }
                    Utility.HoSoCurrent.LstThongTinThamKhao.Add(thongTin);                    
                }
                else
                {                   
                    Utility.HoSoCurrent.LstThongTinThamKhao[Utility.indexThongTinThamKhao] = thongTin;                    
                }
                BidingThongTinThamKhao(Utility.HoSoCurrent.LstThongTinThamKhao);
                divRichBoxTTTK.Style["display"] = "none";
                divShowThongTinThamKhao.Style["display"] = "block";
                RefreshThongTinThamKhao(null);
                Utility.indexThongTinThamKhao = -1;
            }
            catch { }
        }
        #endregion

        #region Update Info
        private void UpdateMucTieuNgheNghiep()
        {
            try
            {
                divRichBoxMTNN.Style["display"] = "block";
                ckeMucTieuNgheNghiep.Text = Utility.HoSoCurrent.MucTieuNgheNghiep;
                divShowMucTieuNgheNghiep.Style["display"] = "none";
            }
            catch { }
        }

        private void UpdateThanhTichNoiBat()
        {
            try
            {
                divRichBoxTTNB.Style["display"] = "block";
                ckeThanhTichNoiBat.Text = Utility.HoSoCurrent.ThanhTichNoiBat;
                divShowThanhTichNoiBat.Style["display"] = "none";
            }
            catch { }
        }

        private void UpdateKyNangNoiBat()
        {
            try
            {
                divRichBoxKNNB.Style["display"] = "block";
                ckeKyNangNoiBat.Text = Utility.HoSoCurrent.KyNangNoiBat;
                divShowKyNangNoiBat.Style["display"] = "none";
            }
            catch { }
        }        
        #endregion

        #region Delete Info
        private void DeleteThanhTichNoiBat()
        {
            try
            {
                Utility.HoSoCurrent.ThanhTichNoiBat = "";
                lblNoiDungTTNB.Text = "";
                ckeThanhTichNoiBat.Text = "";
                divRichBoxTTNB.Style["display"] = "block";
                divShowThanhTichNoiBat.Style["display"] = "none";
            }
            catch { }
        }
        #endregion

        #region Biding
        private void BidingThongTinThamKhao(List<ThongTinThamKhao> lst)
        {
            try
            {
                grvTTTK.DataSource = lst;
                grvTTTK.DataBind();
            }
            catch
            {
            }
        }

        private void BidingKinhNghiemLamViec(List<KinhNghiemLamViec> lst)
        {
            try
            {
                grvKNVL.DataSource = lst;
                grvKNVL.DataBind();
            }
            catch
            {
            }
        }

        private void BidingHocVanBangCap(List<HocVanBangCap> lst)
        {
            try
            {
                grvHVBC.DataSource = lst;
                grvHVBC.DataBind();
            }
            catch { }
        }
        #endregion
                
        protected void UploadButton_Click(object sender, EventArgs e)
        {
            if (fulHinhAnh.HasFile)
            {
                try
                {
                    if (fulHinhAnh.PostedFile.ContentType == "image/jpeg")
                    {
                        if (fulHinhAnh.PostedFile.ContentLength < 102400)
                        {
                            string filename = Path.GetFileName(fulHinhAnh.FileName);
                            fulHinhAnh.SaveAs(Server.MapPath("~/") + filename);
                            //<asp:Label runat="server" id="StatusLabel" text="Upload status: " />                                                     
                            //StatusLabel.Text = "Upload status: File uploaded!";
                            pathimage = filename;
                            imgHinhAnhCaNhan.ImageUrl = pathimage;
                        }
                        else
                        {
                            //StatusLabel.Text = "Upload status: The file has to be less than 100 kb!";
                        }
                    }
                    else
                    {
                        //StatusLabel.Text = "Upload status: Only JPEG files are accepted!";
                    }
                }
                catch (Exception ex)
                {
                    //StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
                }
            }
        }

        private void ShowOnlyDiv(ref HtmlGenericControl div)
        {
            HideDiv(ref divKinhNghiemViecLam);
            HideDiv(ref divKyNangNoiBat);
            HideDiv(ref divMucTieuNgheNghiep);
            HideDiv(ref divThanhTichNoiBat);
            HideDiv(ref divThongTinThamKhao);
            HideDiv(ref divTrinhDoHocVan);
            div.Style["display"] = "block";
        }

        private void ShowDiv(ref HtmlGenericControl div)
        {            
            div.Style["display"] = "block";
        }

        private void HideDiv(ref HtmlGenericControl div)
        {
            div.Style["display"] = "none";
        }

        private void SelectedIndex(ref DropDownList ddl, string text)
        {
            try
            {
                ddl.SelectedIndex = 0;
                if (text != null && text != "")
                {
                    for (int i = 0; i < ddl.Items.Count; i++)
                    {
                        if (ddl.Text == text)
                        {
                            ddl.SelectedIndex = i;
                            break;
                        }
                    }
                }
            }
            catch
            {
                ddl.SelectedIndex = 0;
            }
        }
    }
}
